/*
 * StartovniCasDialog.java
 *
 * Created on 7. leden 2007, 14:36
 */

package cz.results.winter6.view.dialogs.stkategorie;

import cz.results.winter6.model.StartovniCasConfig;
import cz.results.winter6.model.VlCas;
import javax.swing.JDialog;

public class StartovniCasDialog extends JDialog {

    private StartovniCasConfig startovniCasConfig;
    
    public StartovniCasDialog(JDialog parent, boolean modal, StartovniCasConfig startovniCasConfig) {
        super(parent, modal);
        setStartovniCasConfig(startovniCasConfig);
        initComponents();
        
        jTextFieldNazevJizdy.setText(getStartovniCasConfig().getNazevJizdy());
        jTextFieldStartovniCas.setText(VlCas.casToStringNoMillis(getStartovniCasConfig().getStartOd()));
        jTextFieldStartovniInterval.setText(String.valueOf(getStartovniCasConfig().getInterval()));
        jTextFieldJizda.setText(String.valueOf(getStartovniCasConfig().getJizda()));
    }

    public StartovniCasConfig getStartovniCasConfig() {
        return startovniCasConfig;
    }

    public void setStartovniCasConfig(StartovniCasConfig startovniCasConfig) {
        this.startovniCasConfig = startovniCasConfig;
    }
    
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        jLabel1 = new javax.swing.JLabel();
        jTextFieldStartovniCas = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jTextFieldStartovniInterval = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jTextFieldJizda = new javax.swing.JTextField();
        jButtonOk = new javax.swing.JButton();
        jButtonZrus = new javax.swing.JButton();
        jTextFieldNazevJizdy = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();

        setTitle("konfigurace startovn\u00edho \u010dasu");
        setLocationByPlatform(true);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                closeDialog(evt);
            }
        });

        jLabel1.setText("startovn\u00ed \u010das");

        jLabel2.setText("startovn\u00ed interval");

        jLabel3.setText("j\u00edzda");

        jButtonOk.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cz/results/winter6/view/icons/button_ok.png")));
        jButtonOk.setText("ok");
        jButtonOk.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonOkActionPerformed(evt);
            }
        });

        jButtonZrus.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cz/results/winter6/view/icons/button_cancel.png")));
        jButtonZrus.setText("zru\u0161");
        jButtonZrus.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonZrusActionPerformed(evt);
            }
        });

        jLabel4.setText("n\u00e1zev jizdy");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3)
                            .addComponent(jLabel2)
                            .addComponent(jLabel1)
                            .addComponent(jLabel4))
                        .addGap(24, 24, 24))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButtonOk, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(16, 16, 16)))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButtonZrus, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTextFieldJizda, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 137, Short.MAX_VALUE)
                    .addComponent(jTextFieldStartovniInterval, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 137, Short.MAX_VALUE)
                    .addComponent(jTextFieldStartovniCas, javax.swing.GroupLayout.DEFAULT_SIZE, 137, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextFieldNazevJizdy, javax.swing.GroupLayout.DEFAULT_SIZE, 137, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(14, 14, 14)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jTextFieldNazevJizdy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel1)
                    .addComponent(jTextFieldStartovniCas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jTextFieldStartovniInterval, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel3)
                    .addComponent(jTextFieldJizda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 35, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonOk)
                    .addComponent(jButtonZrus))
                .addGap(25, 25, 25))
        );
        pack();
    }// </editor-fold>//GEN-END:initComponents
   
    
    private void jButtonZrusActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonZrusActionPerformed
        setVisible(false);
        dispose();
    }//GEN-LAST:event_jButtonZrusActionPerformed

    private void jButtonOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOkActionPerformed
        startovniCasConfig.setNazevJizdy(jTextFieldNazevJizdy.getText().trim());
        startovniCasConfig.setStartOd(VlCas.stringToCalendar(jTextFieldStartovniCas.getText().trim()));
        startovniCasConfig.setInterval(Integer.valueOf(jTextFieldStartovniInterval.getText().trim()));
        startovniCasConfig.setJizda(Integer.valueOf(jTextFieldJizda.getText().trim()));
        
        setVisible(false);
        dispose();
    }//GEN-LAST:event_jButtonOkActionPerformed
    
    /** Closes the dialog */
    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
        setVisible(false);
        dispose();
    }//GEN-LAST:event_closeDialog
    
        
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonOk;
    private javax.swing.JButton jButtonZrus;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JTextField jTextFieldJizda;
    private javax.swing.JTextField jTextFieldNazevJizdy;
    private javax.swing.JTextField jTextFieldStartovniCas;
    private javax.swing.JTextField jTextFieldStartovniInterval;
    // End of variables declaration//GEN-END:variables
    
}
